package org.jeecg.modules.system.util;

import java.util.Random;

/**
 * 生成邀请码
 */
public class InviteCodeGenerator {
    // 定义可用的字符（排除易混淆的 0/O, 1/I 等）
    private static final String ALLOWED_CHARS = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
    private static final int CODE_LENGTH = 8;
    private static final Random random = new Random();

    /**
     * 生成8位邀请码（大写字母 + 数字，排除易混淆字符）
     */
    public static String generateInviteCode() {
        StringBuilder sb = new StringBuilder(CODE_LENGTH);
        for (int i = 0; i < CODE_LENGTH; i++) {
            int randomIndex = random.nextInt(ALLOWED_CHARS.length());
            sb.append(ALLOWED_CHARS.charAt(randomIndex));
        }
        return sb.toString();
    }
}
